package com.anolesoft.ProductRegistration.mapper;

import com.anolesoft.ProductRegistration.entity.ProductRegistrationDO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.LocalDateTimeTypeHandler;

import java.util.List;


@Mapper
public interface ProuctRegLstrationQueryMapper {
    public static String querySql = "<script>" +
            "SELECT\n" +
            "a.objuid,\n" +
            "a.serial_no as serialNo,\n" +
            "a.fabrecordid,\n" +
            "a.processing_num as processingNum,\n" +
            "a.item_no as itemNo,\n" +
            "a.partid,\n" +
            "a.jx,\n" +
            "a.th,\n" +
            "a.job_num as job,\n" +
            "a.sending_date as sendingDate ,\n" +
            "a.lph,\n" +
            "a.clphzt,\n" +
            "a.material_spec as materialSpec,\n" +
            "a.process_bc as bc,\n" +
            "b.emp_name as theUser,\n" +
            "a.the_date as theDate ,\n" +
            "a.withdraw_user as withdrawUser,\n" +
            "a.withdraw_date as withdrawDate,\n" +
            "a.factory_id as factoryId,\n" +
            "a.state,\n" +
            "a.pass_number as passNumber,\n" +
            "a.qualified_number as qualifiedNumber,\n" +
            "a.concessions_taste as concessionsTaste,\n" +
            "a.waste_num as wasteNum,\n" +
            "a.supplier,\n" +
            "a.returned_type as returnedType," +
            "a.transfer\n"+
            "FROM \n" +
            "MES_WX_DJZ a \n" +
            "left join view_stf_employee b on a.the_user = b.objuid\n" +
            "where 1=1 and a.state!=1 " +
            "<if test =\"o.jx !=null and o.jx != '' \">" +
            "   and a.jx = #{o.jx, jdbcType=VARCHAR} " +
            "</if>" +
            "<if test =\"o.th !=null and o.th != '' \">" +
            "   and a.th like #{o.th, jdbcType=VARCHAR} " +
            "</if>" +
            "<if test =\"o.fabrecordid !=null and o.fabrecordid != '' \">" +
            "   and a.fabrecordid = #{o.fabrecordid, jdbcType=VARCHAR} " +
            "</if>" +
            "<if test =\"o.job !=null and o.job != '' \">" +
            "   and a.job_num = #{o.job, jdbcType=VARCHAR} " +
            "</if>" +
            "<if test =\"o.itemNo !=null and o.itemNo != '' \">" +
            "   and a.item_no = #{o.itemNo, jdbcType=VARCHAR} " +
            "</if>" +
            "<if test =\"o.transfer !=null \">" +
            "   and a.transfer = #{o.transfer, jdbcType=INTEGER} " +
            "</if>" +
            "order by a.the_date desc " +
            "</script>";
    @Results(id = "FenguangYingduRecordQueryResultMap", value = {
            @Result(id = true, column = "objuid", property = "objuid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "jianbiaotiaoma", property = "jianbiaotiaoma", jdbcType = JdbcType.VARCHAR),
            @Result(column = "jixing", property = "jixing", jdbcType = JdbcType.VARCHAR),
            @Result(column = "tuhao", property = "tuhao", jdbcType = JdbcType.VARCHAR),
            @Result(column = "cailiaopaihao", property = "cailiaopaihao", jdbcType = JdbcType.VARCHAR),
            @Result(column = "songjiandanwei", property = "songjiandanwei", jdbcType = JdbcType.VARCHAR),
            @Result(column = "lupihao", property = "lupihao", jdbcType = JdbcType.VARCHAR),
            @Result(column = "jianshu", property = "jianshu", jdbcType = JdbcType.INTEGER),
            @Result(column = "songjiangongxuhao", property = "songjiangongxuhao", jdbcType = JdbcType.VARCHAR),
            @Result(column = "songjiangongxumingcheng", property = "songjiangongxumingcheng", jdbcType = JdbcType.VARCHAR),
            @Result(column = "fenguangshuliang", property = "fenguangshuliang", jdbcType = JdbcType.INTEGER),
            @Result(column = "yingdushuliang", property = "yingdushuliang", jdbcType = JdbcType.INTEGER),
            @Result(column = "yingdushicezhi", property = "yingdushicezhi", jdbcType = JdbcType.VARCHAR),
            @Result(column = "jianyan", property = "jianyan", jdbcType = JdbcType.VARCHAR),
            @Result(column = "beizhu", property = "beizhu", jdbcType = JdbcType.VARCHAR),
            @Result(column = "state", property = "state", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_user", property = "createUser", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_date", property = "createDate", typeHandler = LocalDateTimeTypeHandler.class),
            @Result(column = "shenpiren", property = "shenpiren", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenpishijian", property = "shenpishijian", typeHandler = LocalDateTimeTypeHandler.class),
            @Result(column = "zhizaojilutiaoma", property = "zhizaojilutiaoma", jdbcType = JdbcType.VARCHAR),
            @Result(column = "zhizaojiluid", property = "zhizaojiluid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenqingren", property = "shenqingren", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenqingshijian", property = "shenqingshijian", typeHandler = LocalDateTimeTypeHandler.class),

            @Result(column = "create_user_eid", property = "createUserEid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_user_name", property = "createUserName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenpi_eid", property = "shenpiEid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenpi_name", property = "shenpiName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenqing_eid", property = "shenqingEid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenqing_name", property = "shenqingName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "transfer", property = "transfer", jdbcType = JdbcType.INTEGER)
    })
    @Select(querySql)
    List<ProductRegistrationDO> selectPageList(@Param("o") ProductRegistrationDO ProductRegistrationDO, Page<ProductRegistrationDO> page);

   /* @ResultMap("ProuctRegLstrationQueryMapper")
    @Select(querySql)
    List<FenguangYingduRecordQueryDO> selectList(@Param("o") FenguangYingduRecordQueryDO fenguangYingduRecordQueryDO);*/
}
